﻿using System;
using System.Data;
using System.Collections.Generic;

namespace EntryExit
{
    public class Employee
    {
        public string LPN { get; set; }
        public string GPN { get; set; }
        public string EmployeeName { get; set; }
        public string GradeName { get; set; }
        public string EmailAddress { get; set; }
        public string DepartmentName { get; set; }
        public string OfficeName { get; set; }
        public string Country { get; set; }
        public bool EmployeeStatus { get; set; }
        public DateTime DateOfBirth { get; set; }
        public DateTime JoiningDate { get; set; }
        public DateTime LeavingDate { get; set; }
        public string OfficeID { get; set; }
        public string ServiceLineID { get; set; }
        public string ServiceLineDescription { get; set; }
        public string SubServiceLineID { get; set; }
        public string SubServiceLineDescription { get; set; }
        public string DepartmentID { get; set; }
        public int CodeBlockStatus { get; set; }
        public DateTime EffectiveFrom { get; set; }
        public DateTime EffectiveTo { get; set; }
        public string AuthorityLPN { get; set; }
        public string AuthorityName { get; set; }
        public string WindowsUserName { get; set; }
        public int CardHolderId { get; set; }
        public string Parent { get; set; }
        public bool IsCounselor { get; set; }

        public Employee()
        {
        }

        public Employee(DataRow row)
        {
            LPN = Convert.ToString(row["LPN"]);
            GPN = Convert.ToString(row["GPN"]);
            EmployeeName = Convert.ToString(row["EmployeeName"]);
            GradeName = Convert.ToString(row["GradeName"]);
            EmailAddress = Convert.ToString(row["EmailAddress"]);
            DepartmentName = Convert.ToString(row["DepartmentName"]);
            OfficeName = Convert.ToString(row["OfficeName"]);
            Country = Convert.ToString(row["Country"]);
            EmployeeStatus = (row["EmployeeStatus"] != DBNull.Value) ? Convert.ToBoolean(row["EmployeeStatus"]) : false;
            DateOfBirth = (row["DateOfBirth"] != DBNull.Value) ? Convert.ToDateTime(row["DateOfBirth"]) : DateTime.MinValue;
            JoiningDate = (row["JoiningDate"] != DBNull.Value) ? Convert.ToDateTime(row["JoiningDate"]) : DateTime.MinValue;
            LeavingDate = (row["LeavingDate"] != DBNull.Value) ? Convert.ToDateTime(row["LeavingDate"]) : DateTime.MinValue;
            EffectiveFrom = (row["EffectiveFrom"] != DBNull.Value) ? Convert.ToDateTime(row["EffectiveFrom"]) : DateTime.MinValue;
            EffectiveTo = (row["EffectiveTo"] != DBNull.Value) ? Convert.ToDateTime(row["EffectiveTo"]) : DateTime.MinValue;
            OfficeID = Convert.ToString(row["OfficeID"]);
            ServiceLineID = Convert.ToString(row["ServiceLineID"]);
            ServiceLineDescription = Convert.ToString(row["ServiceLineDescription"]);
            SubServiceLineID = Convert.ToString(row["SubServiceLineID"]);
            SubServiceLineDescription = Convert.ToString(row["SubServiceLineDescription"]);
            DepartmentID = Convert.ToString(row["DepartmentID"]); ;
            CodeBlockStatus = Convert.ToInt32(row["CodeBlockStatus"]);
            AuthorityLPN = Convert.ToString(row["AuthorityLPN"]);
            AuthorityName = Convert.ToString(row["AuthorityName"]);
            WindowsUserName = Convert.ToString(row["WindowsUserName"]);

            CardHolderId = Convert.ToInt32(row["CardholderID"]);
            IsCounselor = Convert.ToBoolean(row["Counselor"]);
        }
    }

    public class EmployeeTree
    {
        public Employee Employee { get; set; }
        public List<EmployeeTree> SubEmployees { get; set; }
    }
}